<?php
declare(strict_types = 1);

namespace app\admin\middleware;

class AdminUserMiddleware
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        //
        // dump($request->pathinfo());
        if (!session('?admin_user') && !preg_match('/login/', $request->pathinfo())) {
            return redirect((string) url('login/index'));
        }
        return $next($request);
    }
}
